<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="css/login.css" rel="stylesheet">

</head>
<body>
<div id="app">
    <template>
        <div class="login">
            <el-form
                    ref="loginForm"
                    :model="loginForm"
                    :rules="loginRules"
                    class="login_form"
            >
                <h3 class="title">登录</h3>
                <el-form-item prop="id">
                    <el-input
                            placeholder="请输入管理员账号"
                            v-model="loginForm.id"
                            clearable
                    >
                    </el-input>
                </el-form-item>

                <el-form-item prop="passwd">
                    <el-input
                            placeholder="请输入密码"
                            v-model="loginForm.passwd"
                            show-password
                    >
                    </el-input>
                </el-form-item>


                <el-form-item style="width: 100%" label-width="24px">
                    <el-button
                            size="medium"
                            type="primary"
                            style="width: 45%"
                            @click="userLogin"
                    >
                        <span>登录</span>
                    </el-button>

                </el-form-item>

            </el-form>
        </div>
    </template>



</div>

<script src="js/vue.js"></script>
<script src="element-ui/lib/index.js"></script>
<link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">

<script src="js/axios-0.18.0.js"></script>

<script>
    new Vue({
        el: "#app",
        data() {
            return {
                aarole: '',
                loginForm: {
                    id: '',
                    name:'',
                    passwd: ''
                },
                loginRules: {
                    id: [
                        {required: true, trigger: 'blur', message: '账号不能为空'}
                    ],
                    passwd: [
                        {required: true, trigger: 'blur', message: '密码不能为空'}
                    ]

                },

                options2: [{
                    value: '男',
                    label: '男'
                }, {
                    value: '女',
                    label: '女'
                }]


            }
        },
        methods: {

            userLogin(){
                 axios({
                     method:"post",
                     url:"http://localhost:8080/superMarket/goods/login",
                     data:this.loginForm
                 }).then(resp =>{
                     if(resp.data == "success"){
                             window.location.href='main.html';
                     }
                 })
             }


        },

    })

</script>

</body>
</html>
